package com.chennan.rebbitmq.leading.controller;

import com.chennan.rebbitmq.leading.producer.MyStreamOutput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chennan
 * @createTime 2021年07月08日 16:55:00
 */
//@RestController
//@RequestMapping("/rabbitmq")
public class SendMessage {

    @Autowired
    private MyStreamOutput myStreamOutput;

    @GetMapping("/send/{msg}")
    public String sendMessage(@PathVariable("msg") String msg){
        MessageChannel messageChannel = myStreamOutput.dataToExcelFastOutput();
        boolean send = messageChannel.send(MessageBuilder.withPayload(msg).setHeader("headerTag", "sendMes").build());
        return "发送到了rabbitmq"+send;
    }

}
